/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.TreeMap;

/**
 * <p>Project: jse2303 - TreeMap1
 * <p>Powered by webrx On 2023-07-20 10:35:06
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class TreeMap1 {
    public static void main(String[] args) {
        //构造方法，默认是按key升序

        //按key 降序
        TreeMap<Integer, String> tm = new TreeMap<>((a, b) -> b - a);
        tm.put(100, "java");
        tm.put(20, "javascript");
        tm.put(1, "c");
        tm.put(150, "python");
        tm.put(1, "python");
        System.out.println(tm);

        //升序
        var tm2 = tm.descendingMap();
        System.out.println(tm2);

    }
}
